﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace RBAC.SqlCache
{
    internal interface ICacheOperator<T>
    {
        ///// <summary> 增加一条数据
        ///// </summary>
        int Add(T model);

        ///// <summary>增加多条数据
        ///// </summary>
        void Add(IList<T> m);

        /// <summary>删除多条数据
        /// </summary>
        bool Delete(List<int> Id, out int mistakeId);

        /// <summary>删除一条数据
        /// </summary>
        bool Delete(int Id);

        /// <summary>获得全部的列表
        /// </summary>
        /// <returns></returns>
        DataSet GetAllList(string strSql);

        /// <summary>
        /// 返回分页数据
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="strWhere"></param>
        /// <param name="OrderBy"></param>
        /// <returns></returns>
        DataSet GetPageList(int PageSize, int PageIndex, string strWhere, string OrderFiled, string OrderBy,out int RecordCount);

        /// <summary>
        /// 返回泛型分页列表
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="strWhere"></param>
        /// <param name="OrderFiled"></param>
        /// <param name="OrderBy"></param>
        /// <returns></returns>
        IList<T> GetPageIList(int PageSize, int PageIndex, string strWhere, string OrderFiled, string OrderBy, out int RecordCount);       

        /// <summary>获得一个实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        T GetModel(int id);

        /// <summary>更新一条数据
        /// </summary>
        bool Update(T model, int id);

        /// <summary>根据SQL语句更新数据 不推荐使用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="strSql"></param>
        /// <param name="sqlParams"></param>
        /// <returns></returns>
        bool Update(int id, string strSql, System.Data.SqlClient.SqlParameter[] sqlParams);

        /// <summary>更新多条数据
        /// </summary>
        bool Update(List<int> ids, string strSql, SqlParameter[] sqlParams, out int mistakeId);
    }
}
